package com.ruoyi.fly.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.fly.domain.AppletMember;
import com.ruoyi.fly.domain.vo.AppletMemberVo;
import com.ruoyi.fly.service.AppletMemberService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Param;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.core.page.TableDataInfo;


@RestController
@RequestMapping("/appletMember")
@Api(tags = "小程序用户管理")
public class AppletMemberController extends BaseController {
    @Autowired
    private AppletMemberService appletMemberService;

    /**
     * 查询小程序用户表列表
     *
     * @param appletMember
     * @return
     */
    @ApiOperation(value = "查询小程序用户表列表")
    @PostMapping("/list")
    public TableDataInfo list(AppletMember appletMember) {
        startPage();
        List<AppletMember> list = appletMemberService.selectAppletMemberList(appletMember);
        return getDataTable(list);
    }


    /**
     * 查询小程序用户表详细
     *
     * @param id
     * @return
     */
    @ApiOperation(value = "根据用户id查询用户表详细")
    @GetMapping(value = "/select/{id}")
    public R getInfo(@PathVariable("id") String id) {
        return R.ok(appletMemberService.selectAppletMemberById(id));
    }


//    @PostMapping
//    public AjaxResult add(@RequestBody AppletMemberVo appletMember) {
//        return toAjax(appletMemberService.insertAppletMember(appletMember));
//    }


    /**
     * 修改小程序用户表
     *
     * @param appletMember
     * @return
     */
    @ApiOperation(value = "修改小程序用户表")
    @PostMapping("/edit")
    public R edit(@RequestBody AppletMemberVo appletMember) {
        return appletMemberService.updateAppletMember(appletMember);
    }

    /**
     * 删除小程序用户表
     *
     * @param ids
     * @return
     */
    @ApiOperation(value = "删除小程序用户表")
    @PostMapping("/delete/{ids}")
    public R remove(@RequestBody List<String> ids) {
        return appletMemberService.deleteAppletMemberByIds(ids);
    }
}
